<template>
	<u-modal
		:show="show"
		:showCancelButton="true"
		title="房主信息"
		@confirm="successHandle"
		@cancel="cancelHandle"
	>
		<u-form labelPosition="left" :rules="rules" :model="ownerInfo" :borderBottom="false" ref="uFormRef">
            <u-form-item label="" prop="ownerName" :borderBottom="false" ref="phone">
                <u-input v-model="ownerInfo.ownerName" placeholder="房主姓名"></u-input>
            </u-form-item>
            <u-form-item label="" prop="ownerBirth" :borderBottom="false" ref="item1">
                <uni-datetime-picker type="datetime" v-model="ownerInfo.ownerBirth" placeholder="出生日期"/>
            </u-form-item>
        </u-form>
	</u-modal>
</template>
<script>

export default {
	data() {
		return {
			show: false,
			ownerInfo: {
				ownerName: '',
				ownerBirth: ''
			},
			rules: {
				'ownerName': {
					type: 'string',
					required: true,
					message: '请填写房主姓名',
					trigger: ['blur', 'change']
				},
				'ownerBirth': {
					type: 'string',
					required: true,
					message: '请选择房主出生时间',
					trigger: ['blur', 'change']
				},
			}
		};
	},
	mounted() {

	},
	methods: {
		showDialog() {
			this.show = true
		},
		successHandle() {
			this.$refs.uFormRef.validate().then(res => {
				uni.$u.toast('校验通过')
                this.$emit('ownerSuccess', JSON.stringify(this.ownerInfo))
				this.cancelHandle()
			}).catch(errors => {
				uni.$u.toast('校验失败')
			})
		},
		cancelHandle() {
			this.show = false
            this.ownerInfo = {
				ownerName: '',
				ownerBirth: ''
			}
		}
	}
}

</script>
<style lang="scss" scoped>
.slot-content {
	width: 100%;
	height: 100%;
}
</style>
